package com.hudongwx.godoffood.utils;

import android.app.Application;
import android.content.SharedPreferences;
import android.util.Log;

import org.json.JSONArray;
import org.json.JSONObject;
import org.xutils.x;

/**
 * Created by hudongwx on 16-11-4.
 */
public class MyApplication extends Application {
    public static String  Uid = "99"; //用于记录登陆状态
    private static SharedPreferences sharedPreferences;
    static String TAG="MyApplication";
    @Override
    public void onCreate() {
        super.onCreate();
        sharedPreferences = getSharedPreferences("uid",MODE_PRIVATE);
        x.Ext.init(this);
        x.Ext.setDebug(true);

    }
    //记录登陆状态
    public static void storage(String uid){
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putString("Uid",uid);
        edit.commit();
    }
    //获得登陆状态
    public static String getStorage(String what){
        String stuta = sharedPreferences.getString(what, "没有数据");
        Log.i(TAG, "getStorage: "+stuta);
        return stuta;
    }
    //保存登陆的头像

    public static void storageIcon(String name,String id,String img){
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putString("name",name);
        edit.putString("id",id);
        edit.putString("img",img);
        edit.commit();
    }
    //存储一个社区的json数据
    public static void setJsonData(String json){
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putString("json",json);
        edit.commit();
    }
    public static String getJsonData(){
        String json = sharedPreferences.getString("json", "没有数据");
        return json;
    }
    //存储一个订单的json数据
    public static void setOrderJsonData(String json){
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putString("order",json);
        edit.commit();
    }
    public static String getOrderJsonData(){
        String json = sharedPreferences.getString("order", "没有数据");
        return json;
    }
}
